#pragma once
#include <vector>
#include <memory>
#include "classfile/class_file.hpp"
#include "rtda/heap/cp_classRef.h"

namespace jvm {
    namespace heap {

        struct ExceptionHandler {
            int startPc;
            int endPc;
            int handlerPc;
            std::shared_ptr<ClassRef> pCatchType;
        };

        class ExceptionTable {
        private:
            std::vector<std::shared_ptr<ExceptionHandler>> _handlers;

        public:
            ExceptionTable(const std::vector<std::shared_ptr<classfile::ExceptionTableEntry>>& entries,
                std::shared_ptr<heap::ConstantPool> pCp);

            std::shared_ptr<ExceptionHandler> findExceptionHandler(
                std::shared_ptr<Class> pExClass, int pc) const;
        };

    } // namespace heap
} // namespace jvm